package com.aoyebobi;

import java.awt.*;

/**
 * @Description
 * @Author aoyebobi
 * @Date 2024-09-04
 */

public class FlowLayoutDemo {
    public static void main(String[] args) {
        Frame frame = new Frame("FlowLayout");
        frame.setBounds(100,100,400,300);
        //设置布局为流式布局，左对齐，组件之间的间距为20，组件之间的行间距为40
        frame.setLayout(new FlowLayout(FlowLayout.LEFT,20,40));

        Button button1 = new Button("button1");
        Button button2 = new Button("button2");
        Button button3 = new Button("button3");
        Button button4 = new Button("button4");
        Button button5 = new Button("button5");

        button1.setBackground(Color.BLACK);
        button2.setBackground(Color.BLUE);
        button3.setBackground(Color.YELLOW);
        button4.setBackground(Color.GREEN);
        button5.setBackground(Color.CYAN);

        frame.add(button1);
        frame.add(button2);
        frame.add(button3);
        frame.add(button4);
        frame.add(button5);

        frame.setVisible(true);
    }
}
